package com.sskj.ffex.p.activity;

import com.lzy.okgo.OkGo;
import com.lzy.okrx2.adapter.FlowableBody;
import com.sskj.ffex.common.Constants;
import com.sskj.ffex.m.HttpConfig;
import com.sskj.ffex.m.bean.CommissionBean;
import com.sskj.ffex.m.bean.HaiPageBean;
import com.sskj.ffex.m.bean.HttpData;
import com.sskj.ffex.m.http.JsonConverter;
import com.sskj.ffex.p.base.BasePresenter;
import com.sskj.ffex.v.activity.CommissionDetailActivity;

import java.util.List;

import io.reactivex.Flowable;

public class CommissionDetailsPresenter extends BasePresenter<CommissionDetailActivity> {
    public Flowable<List<CommissionBean>> loadData(int page, String dateFrom, String dateTo) {
        return OkGo.<HttpData<HaiPageBean<CommissionBean>>>post(HttpConfig.BASE_URL+HttpConfig.AGENT_COSTUM)
                .params("act", "commission_info")
                .params("start_time", dateFrom)
                .params("end_time", dateTo)
                .params("p", page)
                .params("size", Constants.PAGE_SIZE)
                .converter(new JsonConverter<HttpData<HaiPageBean<CommissionBean>>>() {})
                .adapt(new FlowableBody<>())
                .map(listHttpData -> listHttpData.getData().getRes());

    }
}
